home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / jovept1.arc / FORMAT.C < prev    next >
Text File  |  1985-05-30  |  2KB  |  167 lines

  1. /* format.c */
  2.  
  3. /* JOVE/MSDOS. K. Mitchum 1/85 */
  4. /* Modifications for personal use only. */
  5. /* original code J. Payne LSRHS 5/83 */
  6. /* Ken Mitchum */
  7. /* University of Pittsburgh */
  8. /* Decision Systems Laboratory */
  9.  
  10. /* Jonathan Payne at Lincoln-Sudbury Regional High School 5-25-83
  11.  
  12.    format.c
  13.  
  14.    contains procedures that call _doprnt */
  15.  
  16.  
  17.  
  18.  
  19. #include "jove.h"
  20.  
  21.  
  22. /* VARARGS1 */
  23.  
  24. char *
  25. sprint(fmt, args)
  26. char    *fmt;
  27. {
  28.     static char line[100];
  29.  
  30.     format(line, fmt, &args);
  31.     return line;
  32. }
  33.  
  34.  
  35. /* VARARGS2 */
  36.  
  37. char *
  38. sprintf(str, fmt, args)
  39. char    *str,
  40.     *fmt;
  41. {
  42.     format(str, fmt, &args);
  43.     return str;
  44. }
  45.  
  46. /* VARARGS1 */
  47.  
  48. s_mess(fmt, args)
  49. char    *fmt;
  50. {
  51.     if (Input)
  52.         return;
  53.     format(mesgbuf, fmt, &args);
  54.     message(mesgbuf);
  55. }
  56.  
  57.  
  58. /*-------------------------o.s. dependent-------------------------*/
  59.  
  60.  
  61. #ifdef UNIX
  62.  
  63. /* VARARGS2 */
  64.  
  65. format(buf, fmt, args)
  66. char    *buf,
  67.     *fmt;
  68. int    *args;
  69. {
  70.     IOBUF    strbuf;
  71.  
  72.     strbuf.io_flag = 0;
  73.     strbuf.io_base = strbuf.io_ptr = buf;
  74.     strbuf.io_cnt = 32767;
  75.     _doprnt(fmt, args, &strbuf);
  76.     Putc('\0', &strbuf);
  77. }
  78.  
  79. /* VARARGS1 */
  80.  
  81. char *
  82. printf(fmt, args)
  83. char    *fmt;
  84. {
  85.     _doprnt(fmt, &args, &termout);
  86. }
  87.  
  88.  
  89. /* as far as i can tell, this routine is never called */
  90.  
  91. _strout(string, count, adjust, file, fillch)
  92. register char *string;
  93. register int count;
  94. int adjust;
  95. register IOBUF    *file;
  96. {
  97.  
  98.     while (adjust < 0) {
  99.         if (*string=='-' && fillch=='0') {
  100.             Putc(*string++, file);
  101.             count--;
  102.         }
  103.         Putc(fillch, file);
  104.         adjust++;
  105.     }
  106.     while (--count >= 0)
  107.         Putc(*string++, file);
  108.     while (adjust) {
  109.         Putc(fillch, file);
  110.         adjust--;
  111.     }
  112. }
  113.  
  114.  
  115. #else
  116.  
  117. /* clone */
  118.  
  119. /* these are viable only with the big memory model */
  120.  
  121. static int j;
  122. static unsigned char **store[10];
  123.  
  124. static stab(to,from,leng)    /* like a call to write */
  125. unsigned to;
  126. unsigned char *from;
  127. unsigned leng;
  128. {
  129.     movmem(from,*store[to],leng);
  130.     *store[to]+=leng;
  131.     **store[to]=0;
  132. }
  133.  
  134. format(buf, fmt, args)
  135. char *buf, *fmt;
  136. unsigned int *args;
  137. {
  138.     int r;
  139.  
  140.     store[j]=&buf;
  141.     if(j>9) {
  142.         bdos(9,"JOVEFORMAT$");
  143.         _exit(0xFFF0);
  144.     }
  145.     r=_fmtout(&stab,j++,fmt,args);
  146.     --j;
  147.     return r;
  148. }
  149.  
  150. char *
  151. printf(fmt,args)
  152. unsigned char *fmt;
  153. unsigned args;
  154. {
  155.     extern int write();
  156.  
  157.     return _fmtout(&write,1,fmt,&args);
  158. }
  159.  
  160. flusho()
  161. {
  162. }
  163.  
  164. #endif
  165.  
  166. /* end */
  167.